//
//  HQTabBarController.swift
//  TodayNews
//
//  Created by 郝庆 on 16/8/22.
//  Copyright © 2016年 haoqing. All rights reserved.
//

import UIKit

class HQTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
     
        // 添加子控制器
        addChildViewControllers()
        
        // 设置tabBar的相关属性
        tabBar.tintColor = HQColor(111, g: 111, b: 111, a: 1.0)
    }
    
    /**
     添加所有的子控制器
     */
    private func addChildViewControllers() {
        
        addChildViewController(HQHomeViewController(), title: "首页", imageName: "home_tabbar_22x22_", selectedImageName: "home_tabbar_press_22x22_")
        addChildViewController(HQVideoViewController(), title: "视频", imageName: "video_tabbar_22x22_", selectedImageName: "video_tabbar_press_22x22_")
        addChildViewController(HQNewCareViewController(), title: "关注", imageName: "newcare_tabbar_22x22_", selectedImageName: "newcare_tabbar_press_22x22_")
        addChildViewController(HQMineViewController(), title: "我的", imageName: "mine_tabbar_22x22_", selectedImageName: "mine_tabbar_press_22x22_")
        
    }
    
    private func addChildViewController(vc: UIViewController, title: String,imageName: String, selectedImageName:String) {
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: selectedImageName)
        vc.title = title
        
        // 将控制器包装成导航控制器的根控制器
        let nav = HQNavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
}


